﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Jw.Core;

namespace Jw.Web.Areas.Basic.Common
{
    [Module("Pacm")]
    public class BasicService : ServiceBase<ModelBase>
    {
        //审核表单
        public int Audit(string tableName, string idKey, string billNo, string status, string comment)
        {
            db.UseTransaction(true);

            var userName = BasicHelper.GetUserName();
            var pUpdate = ParamUpdate.Instance()
                .Update(tableName)
                .Column("ApproveState", status)
                .Column("ApproveRemark", comment)
                .Column("ApprovePerson", userName)
                .Column("ApproveDate", DateTime.Now)
                .AndWhere(idKey, billNo); //关键字

            var rowsAffected = BuilderParse(pUpdate).Execute();


            if (rowsAffected < 0)
            {
                db.Rollback();
                return rowsAffected;
            }

            db.Commit();
            return rowsAffected;
        }
    }
}